package com.cloudm.technician.ui.modules.cloudm_box.machine

import android.os.Bundle
import com.cloudm.technician.R
import com.cloudm.technician.extensions.addFragmentToActivity
import com.cloudm.technician.ui.base.BaseActivity

/**
 * 作者: wesley
 * 时间: 2017/12/20
 * 描述: 机器类型、品牌、型号界面
 */
class MachineActivity : BaseActivity(), MachineFragment.OnTitleReceiveListener {
    private var typeId = -1
    private var brandId = -1
    private var modelId = -1
    private var flag = 0

    override fun handleBundle(bundle: Bundle) {
        flag = bundle.getInt("flag")
        typeId = bundle.getInt("typeId")
        brandId = bundle.getInt("brandId")
        modelId = bundle.getInt("modelId")
    }

    override fun initVariables() {

    }

    override fun initViews(savedInstanceState: Bundle?) {
        val fragment = manager.findFragmentById(
                R.id.common_content) as? MachineFragment ?: MachineFragment.newInstance(flag,
                typeId, brandId, modelId)
        fragment.listener = this
        addFragmentToActivity(manager, fragment)
    }

    override fun initListener() {

    }

    override fun onTitleReceive(title: String) {
        headerTitleString = title
        displayHomeAsUpEnabled = true
    }
}